package com.springweb.unit5.dao.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.springweb.unit5.dao.SpittleRepository;
import com.springweb.unit5.domain.Spittle;

@Repository("spittleRepository")
public class SpittleRepositoryImpl implements SpittleRepository {

	@Override
	public List<Spittle> findSpittles(long max, int count) {
		return this.getSpittles(max, count);
	}

	private List<Spittle> getSpittles(long max,int count) {
		List<Spittle> result = new ArrayList<Spittle>();
		long size = max + count;
		for (long i = max; i < size; i++) {
			Spittle spittle = new Spittle(i, "Spittle-" + i, new Date());
			result.add(spittle);
		}
		return result;
	}

	@Override
	public Spittle findSpittle(long id) {
		return this.getSpittle(id);
	}
	
	private Spittle getSpittle(long id) {
//		Spittle spittle = new Spittle(id, "Spittle-" + id, new Date());
//		return spittle;
		return null;
	}
}
